package com.black.cat.jvm.rtda.heap.constantpool;


import com.black.cat.jvm.classfile.constantpool.impl.ConstantInfoMethodref;
import com.black.cat.jvm.rtda.heap.methodarea.JMethod;


public class MethodRef extends SymRef {

    private JMethod method;
    public String name;
    public String descriptor;

    public static MethodRef newMethodRef(RunTimeConstantPool runTimeConstantPool, ConstantInfoMethodref refInfo) {
        MethodRef ref = new MethodRef();
        ref.runTimeConstantPool = runTimeConstantPool;
        ref.copyMemberRefInfo(refInfo);
        return ref;
    }

    public void copyMemberRefInfo(ConstantInfoMethodref refInfo) {
        this.className = refInfo.getClassName();
        String[] split = refInfo.getNameAndType().split(":");
        this.name = split[0];
        this.descriptor = split[1];
    }

    public JMethod ResolvedMethod() {
        if (null == this.method) {
            this.resolveMethodRef();
        }
        return this.method;
    }

    private void resolveMethodRef() {

    }


}
